import { request } from "@/utils/http";
import { CityOrDistrictResponse, Department, DoctorItem, HosTypesResponse, ProvinceResponse, ReqGetHospitalDetail, ReqGetHospitalListParams, ReqGetHospitalListResponse, ReqGetScheduleParams, ReqScheduleResponse } from "./model/hospitalListTypes";

/**
 * 获取省份的信息
 */
export function reqGetAllProvinces(){
  return request.get<any, ProvinceResponse>('/admin/cmn/dict/findByDictCode/Province');
}

/**
 * 获取市和县的信息
 */
export function reqGetCityOrDistrict(parentId: number){
  return request.get<any, CityOrDistrictResponse>(`/admin/cmn/dict/findByParentId/${parentId}`);
}

/**
 * 获取医院等级的信息
 */
export function reqGetHosTypes(){
  return request.get<any, HosTypesResponse>('/admin/cmn/dict/findByDictCode/Hostype');
}

/**
 * 获取医院列表数据
 */
export function reqGetHospitalList({page, limit, ...args}: ReqGetHospitalListParams){
  return request.get<any, ReqGetHospitalListResponse>(`/admin/hosp/hospital/${page}/${limit}`, {
    params: args
  })
}

/**
 * 获取单个医院的数据
 */
export function reqGetHospitalDetail(hosid: string){
  return request.get<any, ReqGetHospitalDetail>(`/admin/hosp/hospital/show/${hosid}`);
}

/**
 * 获取某个医院所有的科室
 */
export function reqGetDepartments(hoscode: string){
  return request.get<any, Department[]>(`/admin/hosp/department/${hoscode}`);
}

/**
 * 获取某个医院中某个科室的排班规则
 */
export function reqGetHospitalSchedule({page, limit, hoscode, depcode}: ReqGetScheduleParams){
  return request.get<any, ReqScheduleResponse>(`/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`)
}

/**
 * 获取某个医院中某个科室未来某一天的排班医生
 */
export function reqGetDoctors(hoscode: string, depcode: string, workDate: string){
  return request.get<any, DoctorItem[]>(`/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`);
}

/**
 * 更新某个医院的上下线状态
 */
export function reqUpdateHospitalStatus(id: string, status: number){
  return request.get<any, null>(`/admin/hosp/hospital/updateStatus/${id}/${status}`);
}